package tec;

import java.awt.BorderLayout;
import java.awt.Container;
import javax.swing.BorderFactory;
import javax.swing.JFrame;
import javax.swing.JProgressBar;
import javax.swing.border.Border;

public class JournalProgressBar implements Journal {

	JProgressBar progressBar;
	long nbPlacePrise;
	long nbPlace;
	
	public JournalProgressBar()
	{
		JFrame f = new JFrame("Journalisation de l'autobus");
	    f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
	    Container content = f.getContentPane();
	    progressBar = new JProgressBar();
	    progressBar.setValue(0);
	    progressBar.setStringPainted(true);
	    Border border = BorderFactory.createTitledBorder("Remplissage");
	    progressBar.setBorder(border);
	    content.add(progressBar, BorderLayout.NORTH);
	    f.setSize(300, 100);
	    f.setVisible(true);
	}
	
	public void ajouterUnAssis() {
		nbPlacePrise++;
	}

	public void ajouterUnDebout() {
		nbPlacePrise++;
	}

	public void enleverUnAssis() {
		nbPlacePrise--;
	}

	public void enleverUnDebout() {
		nbPlacePrise--;
	}

	public void enleverUnPassager() {
		nbPlacePrise--;
	}

	public void changerArret() {
		progressBar.setValue((int) (nbPlacePrise * 100 / nbPlace));
	}

	public void fixerMaxPlace(long nbAssis, long nbDebout) 
	{
		nbPlace = nbAssis + nbDebout;
		progressBar.setValue((int) (nbPlacePrise * 100 / nbPlace));
	}

}
